package com.blog.log;

import java.net.URL;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;

import org.apache.log4j.Logger;
import org.apache.log4j.PropertyConfigurator;
/**
 * web状态下的日志系统
 * @author Administrator
 *
 */
public final class InitLogServlet extends HttpServlet {
	static Logger log = Logger.getLogger(InitLogServlet.class);
	/**
	 * 
	 */
	private static final long serialVersionUID = -7588909267134780809L;

	/**
	 * Constructor of the object.
	 */
	public InitLogServlet() {
		super();
	}

	/**
	 * Destruction of the servlet. <br>
	 */
	public void destroy() {
		super.destroy(); // Just puts "destroy" string in log
		// Put your code here
	}

 

	/**
	 * Initialization of the servlet. <br>
	 *
	 * @throws ServletException if an error occurs
	 */
	public void init() throws ServletException {
		URL url = ClassLoader.getSystemResource("");
		System.out.println("物理路径为："+url.toString());
		String subStr = url.toString().substring(6);
		System.out.println(subStr);
		PropertyConfigurator.configure(subStr+FinalProperty.getLogRelativePath());
		log.info("日志系统已经准备就绪。");
	}

}
